<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<!-- This file documents the use of the GNU compilers.

Copyright (C) 1988-2023 Free Software Foundation, Inc.

Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.3 or
any later version published by the Free Software Foundation; with the
Invariant Sections being "Funding Free Software", the Front-Cover
Texts being (a) (see below), and with the Back-Cover Texts being (b)
(see below).  A copy of the license is included in the section entitled
"GNU Free Documentation License".

(a) The FSF's Front-Cover Text is:

A GNU Manual

(b) The FSF's Back-Cover Text is:

You have freedom to copy and modify this GNU Manual, like GNU
     software.  Copies published by the Free Software Foundation raise
     funds for GNU development. -->
<!-- Created by GNU Texinfo 6.7, http://www.gnu.org/software/texinfo/ -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Interoperation (Using the GNU Compiler Collection (GCC))</title>

<meta name="description" content="Interoperation (Using the GNU Compiler Collection (GCC))">
<meta name="keywords" content="Interoperation (Using the GNU Compiler Collection (GCC))">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="Generator" content="makeinfo">
<link href="index.html" rel="start" title="Top">
<link href="Indices.html" rel="index" title="Indices">
<link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
<link href="Trouble.html" rel="up" title="Trouble">
<link href="Incompatibilities.html" rel="next" title="Incompatibilities">
<link href="Actual-Bugs.html" rel="prev" title="Actual Bugs">
<style type="text/css">
<!--
a.summary-letter {text-decoration: none}
blockquote.indentedblock {margin-right: 0em}
div.display {margin-left: 3.2em}
div.example {margin-left: 3.2em}
div.lisp {margin-left: 3.2em}
kbd {font-style: oblique}
pre.display {font-family: inherit}
pre.format {font-family: inherit}
pre.menu-comment {font-family: serif}
pre.menu-preformatted {font-family: serif}
span.nolinebreak {white-space: nowrap}
span.roman {font-family: initial; font-weight: normal}
span.sansserif {font-family: sans-serif; font-weight: normal}
ul.no-bullet {list-style: none}
-->
</style>


</head>

<body lang="en_US">
<span id="Interoperation"></span><div class="header">
<p>
Next: <a href="Incompatibilities.html" accesskey="n" rel="next">Incompatibilities</a>, Previous: <a href="Actual-Bugs.html" accesskey="p" rel="prev">Actual Bugs</a>, Up: <a href="Trouble.html" accesskey="u" rel="up">Trouble</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Indices.html" title="Index" rel="index">Index</a>]</p>
</div>
<hr>
<span id="Interoperation-1"></span><h3 class="section">14.2 Interoperation</h3>

<p>This section lists various difficulties encountered in using GCC
together with other compilers or with the assemblers, linkers,
libraries and debuggers on certain systems.
</p>
<ul>
<li> On many platforms, GCC supports a different ABI for C++ than do other
compilers, so the object files compiled by GCC cannot be used with object
files generated by another C++ compiler.

<p>An area where the difference is most apparent is name mangling.  The use
of different name mangling is intentional, to protect you from more subtle
problems.
Compilers differ as to many internal details of C++ implementation,
including: how class instances are laid out, how multiple inheritance is
implemented, and how virtual function calls are handled.  If the name
encoding were made the same, your programs would link against libraries
provided from other compilers&mdash;but the programs would then crash when
run.  Incompatible libraries are then detected at link time, rather than
at run time.
</p>
</li><li> On some BSD systems, including some versions of Ultrix, use of profiling
causes static variable destructors (currently used only in C++) not to
be run.

</li><li> On a SPARC, GCC aligns all values of type <code>double</code> on an 8-byte
boundary, and it expects every <code>double</code> to be so aligned.  The Sun
compiler usually gives <code>double</code> values 8-byte alignment, with one
exception: function arguments of type <code>double</code> may not be aligned.

<p>As a result, if a function compiled with Sun CC takes the address of an
argument of type <code>double</code> and passes this pointer of type
<code>double *</code> to a function compiled with GCC, dereferencing the
pointer may cause a fatal signal.
</p>
<p>One way to solve this problem is to compile your entire program with GCC.
Another solution is to modify the function that is compiled with
Sun CC to copy the argument into a local variable; local variables
are always properly aligned.  A third solution is to modify the function
that uses the pointer to dereference it via the following function
<code>access_double</code> instead of directly with &lsquo;<samp>*</samp>&rsquo;:
</p>
<div class="example">
<pre class="example">inline double
access_double (double *unaligned_ptr)
{
  union d2i { double d; int i[2]; };

  union d2i *p = (union d2i *) unaligned_ptr;
  union d2i u;

  u.i[0] = p-&gt;i[0];
  u.i[1] = p-&gt;i[1];

  return u.d;
}
</pre></div>

<p>Storing into the pointer can be done likewise with the same union.
</p>
</li><li> On Solaris, the <code>malloc</code> function in the <samp>libmalloc.a</samp> library
may allocate memory that is only 4 byte aligned.  Since GCC on the
SPARC assumes that doubles are 8 byte aligned, this may result in a
fatal signal if doubles are stored in memory allocated by the
<samp>libmalloc.a</samp> library.

<p>The solution is to not use the <samp>libmalloc.a</samp> library.  Use instead
<code>malloc</code> and related functions from <samp>libc.a</samp>; they do not have
this problem.
</p>
</li><li> On the HP PA machine, ADB sometimes fails to work on functions compiled
with GCC.  Specifically, it fails to work on functions that use
<code>alloca</code> or variable-size arrays.  This is because GCC doesn&rsquo;t
generate HP-UX unwind descriptors for such functions.  It may even be
impossible to generate them.

</li><li> Debugging (<samp>-g</samp>) is not supported on the HP PA machine, unless you use
the preliminary GNU tools.

</li><li> Taking the address of a label may generate errors from the HP-UX
PA assembler.  GAS for the PA does not have this problem.

</li><li> Using floating point parameters for indirect calls to static functions
will not work when using the HP assembler.  There simply is no way for GCC
to specify what registers hold arguments for static functions when using
the HP assembler.  GAS for the PA does not have this problem.

</li><li> In extremely rare cases involving some very large functions you may
receive errors from the HP linker complaining about an out of bounds
unconditional branch offset.  This used to occur more often in previous
versions of GCC, but is now exceptionally rare.  If you should run
into it, you can work around by making your function smaller.

</li><li> GCC compiled code sometimes emits warnings from the HP-UX assembler of
the form:

<div class="example">
<pre class="example">(warning) Use of GR3 when
  frame &gt;= 8192 may cause conflict.
</pre></div>

<p>These warnings are harmless and can be safely ignored.
</p>
</li><li> In extremely rare cases involving some very large functions you may
receive errors from the AIX Assembler complaining about a displacement
that is too large.  If you should run into it, you can work around by
making your function smaller.

</li><li> The <samp>libstdc++.a</samp> library in GCC relies on the SVR4 dynamic
linker semantics which merges global symbols between libraries and
applications, especially necessary for C++ streams functionality.
This is not the default behavior of AIX shared libraries and dynamic
linking.  <samp>libstdc++.a</samp> is built on AIX with &ldquo;runtime-linking&rdquo;
enabled so that symbol merging can occur.  To utilize this feature,
the application linked with <samp>libstdc++.a</samp> must include the
<samp>-Wl,-brtl</samp> flag on the link line.  G++ cannot impose this
because this option may interfere with the semantics of the user
program and users may not always use &lsquo;<samp>g++</samp>&rsquo; to link his or her
application.  Applications are not required to use the
<samp>-Wl,-brtl</samp> flag on the link line&mdash;the rest of the
<samp>libstdc++.a</samp> library which is not dependent on the symbol
merging semantics will continue to function correctly.

</li><li> An application can interpose its own definition of functions for
functions invoked by <samp>libstdc++.a</samp> with &ldquo;runtime-linking&rdquo;
enabled on AIX.  To accomplish this the application must be linked
with &ldquo;runtime-linking&rdquo; option and the functions explicitly must be
exported by the application (<samp>-Wl,-brtl,-bE:exportfile</samp>).

</li><li> AIX on the RS/6000 provides support (NLS) for environments outside of
the United States.  Compilers and assemblers use NLS to support
locale-specific representations of various objects including
floating-point numbers (&lsquo;<samp>.</samp>&rsquo; vs &lsquo;<samp>,</samp>&rsquo; for separating decimal
fractions).  There have been problems reported where the library linked
with GCC does not produce the same floating-point formats that the
assembler accepts.  If you have this problem, set the <code>LANG</code>
environment variable to &lsquo;<samp>C</samp>&rsquo; or &lsquo;<samp>En_US</samp>&rsquo;.

</li><li> <span id="index-fdollars_002din_002didentifiers-1"></span>
Even if you specify <samp>-fdollars-in-identifiers</samp>,
you cannot successfully use &lsquo;<samp>$</samp>&rsquo; in identifiers on the RS/6000 due
to a restriction in the IBM assembler.  GAS supports these
identifiers.

</li></ul>

<hr>
<div class="header">
<p>
Next: <a href="Incompatibilities.html" accesskey="n" rel="next">Incompatibilities</a>, Previous: <a href="Actual-Bugs.html" accesskey="p" rel="prev">Actual Bugs</a>, Up: <a href="Trouble.html" accesskey="u" rel="up">Trouble</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Indices.html" title="Index" rel="index">Index</a>]</p>
</div>



</body>
</html>
